<?php
defined( '_VALID_MOS' ) or die('<script>window.location.href="http://www.kinifurniture.com";</script>');
//============================= SUBMIT REGISTRATION INFO======================================

			$val_check1='checked="checked"';
			$val_check7='checked="checked"';
 
if($error==1)
	$msg=$lang['username_already_exist'];
if($error==2)
	$msg=$lang['email_already_exist'];
if($error==3)
	$msg=$lang['all_already_exist'];

if($sumbitREG)
{	
	if ($inp_tob=='ToB01') $inp_tob1='Retail';
	if ($inp_tob=='ToB02') $inp_tob1='Wholesale';
	if ($inp_tob=='ToB03') $inp_tob1='Manufacturer';
	if ($inp_tob=='ToB04') $inp_tob1='Designer/Architect';
	if ($inp_tob=='ToB05') $inp_tob1=$inp_tob_other;
	$Sel_Result2=$dbh->query("select * from anggota where username='$inp_username'"); 
	$Sel_Result3=$dbh->query("select * from anggota where email='$inp_email'"); 
	if(@mysql_num_rows($Sel_Result2)>0) $error_message='<font color="red">( Username already exists ) !!!</font>';
	if(@mysql_num_rows($Sel_Result3)>0) $error_message='<font color="red">( Email address already exists ) !!!</font>';
	if(@mysql_num_rows($Sel_Result2)>0 and @mysql_num_rows($Sel_Result3)>0) $error_message='<font color="red">Username and Email already exists !!!</font>';
	if(@mysql_num_rows($Sel_Result2)==0 and @mysql_num_rows($Sel_Result3)==0)
	{
		$qrySavePage="insert into anggota (
					user_id,
					username,
					password,
					nama,
					tav_number,
					perus,
					alamat1,
					zipcode,
					kota,
					negara,
					email,
					telp,
					newsletter,
					komentar,
					tob,
					fax) values (
					'',
					'$inp_username',
					'$inp_password',
					'$inp_name',
					'$inp_tav',
					'$inp_company',
					'$inp_address',
					'$inp_zip',
					'$inp_city',
					'$inp_country',
					'$inp_email',
					'$inp_telp',
					'$inp_newsletter',
					'$inp_comment',
					'$inp_tob1',
					'$inp_fax' )";
	  $result=$dbh->query($qrySavePage);
//		$SITE_URL='http://www.bsmindonesia.com';
	if($result)
		{
//		if($functions->send_code('act',$admin_email,$SITE_URL))
			$subject='New Member Registration';
//			$link="http://www.bsmindonesia.com/admin.php?show=user_manager&search=$inp_username";
			$isi_mail = "Username: $inp_username
			Name: $inp_name
			Company: $inp_company
			TAV Number: $inp_tav
			Address : $inp_address
			Zip Code: $inp_zip
			City: $inp_city
			Country: $inp_country
			Email Address: $inp_email
			Telp: $inp_telp
			Fax: $inp_fax
			Type of Business: $inp_tob1
			Comment: $inp_comment \n";
//			Please click link below to activate account:
//			$link";
								mail($admin_email, $subject, $isi_mail,
					 "From: $admin_email\r\n"
					."Reply-To: $admin_email\r\n"
					."X-Mailer: PHP/" . phpversion());
			$isi_mail2 = "Hello, \n
			Thank you for your interest in KINI! Your registration is in process.
			We will come back to you within the next 48 hours.
			Only short list registration will be accepted. \n
			Kind regards,
			KINI";
								mail($inp_email, $subject, $isi_mail2,
					 "From: $admin_email\r\n"
					."Reply-To: $admin_email\r\n"
					."X-Mailer: PHP/" . phpversion());

//		$functions->ngirim_mail('admin_act',$admin_email,$SITE_URL);
//			echo "<script>alert('$admin_email');</script>";
			echo '<script>document.location="index.php?show=message&msg=reg01";</script>';
		}
		else
			echo '<script>document.location="index.php?show=message&msg=act02";</script>';
		
	}
//	}
	else
	{
		$val_username=$inp_username; 
		$val_password=$inp_password;
		$val_password2=$inp_password;
		$val_name=$inp_name;
		$val_tav=$inp_tav;
		$val_company=$inp_company;
		$val_address=$inp_address;
		$val_zip=$inp_zip;
		$val_city=$inp_city;
		$val_country=$inp_country;
		$val_email=$inp_email;
		$val_telp=$inp_telp;
		$val_fax=$inp_fax;
		$val_comment=$inp_comment;
		$section='Add New User';
		if ($inp_newsletter=='Y')
		{
			$val_check1='checked="checked"';
			$val_check2='';
		} else
		{
			$val_check1='';
			$val_check2='checked="checked"';
		}
		$val_check3='';
		$val_check4='';
		$val_check5='';
		$val_check6='';
		$val_check7='';
		$val_check8=$inp_tob_other;
		if ($inp_tob=='ToB01') $val_check3='checked="checked"';
		if ($inp_tob=='ToB02') $val_check4='checked="checked"';
		if ($inp_tob=='ToB03') $val_check5='checked="checked"';
		if ($inp_tob=='ToB04') $val_check6='checked="checked"';
		if ($inp_tob=='ToB05') $val_check7='checked="checked"';
	}
//		echo '<script>document.location="index.php?show=register&error=3";</script>';
	
}				
?>
	